//
//  AudioPlayController.m
//  Session--Test
//
//  Created by lanou3g on 15/12/16.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "AudioPlayController.h"
#import "AudioPlayer.h"
#import "UrlHelper.h"
#import "UrlAPI.pch"

@interface AudioPlayController ()<UITableViewDataSource, UITableViewDelegate,AudioPlayerDelegate>
/** 顶部分页显示PageControl */
@property (weak, nonatomic) IBOutlet UIPageControl *pageControl;
/** 广播列表 */
@property (weak, nonatomic) IBOutlet UITableView *audioListTableView;
/** 电台图片(大图) */
@property (weak, nonatomic) IBOutlet UIImageView *audioImageView;
/** 显示正在播放的动画 */
@property (weak, nonatomic) IBOutlet UIView *isPlayingAnimationView;
/** 收听数 */
@property (weak, nonatomic) IBOutlet UILabel *listenCountLabel;
/** 喜欢数(心形) */
@property (weak, nonatomic) IBOutlet UILabel *heartCountLabel;
/** 开始时间 */
@property (weak, nonatomic) IBOutlet UILabel *beginTimeLabel;
/** 总时间 */
@property (weak, nonatomic) IBOutlet UILabel *totalTimeLabel;
/** 进度条 */
@property (weak, nonatomic) IBOutlet UISlider *pressSlider;
/** 电台图片(小图) */
@property (weak, nonatomic) IBOutlet UIImageView *smallAudioImage;
/** 电台主题 */
@property (weak, nonatomic) IBOutlet UILabel *audioTitleLabel;
/** 电台作者 */
@property (weak, nonatomic) IBOutlet UILabel *audioAuthorLabel;
/** 订阅/取消 */
@property (weak, nonatomic) IBOutlet UIButton *bookOrCancelButton;
/** 显示评论的TableView */
@property (weak, nonatomic) IBOutlet UITableView *commentTableView;
/** 音乐播放的类 */
@property (nonatomic, strong) AudioPlayer *player;
/** 当前的广播索引 */
@property (nonatomic, assign) NSInteger currentIndex;
@end

@implementation AudioPlayController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.player = [AudioPlayer shareAudioPlayer];
    self.audioListTableView.backgroundColor = [UIColor orangeColor];
    self.commentTableView.backgroundColor = [UIColor magentaColor];
//    self.audioListTableView.dataSource = self;
//    self.audioListTableView.delegate = self;
    UrlHelper *helper = [[UrlHelper alloc] init];
    [helper getCategoryItemModelWithUrl:Head urlBody:Body success:^(NSArray *array) {
        
    } fail:nil];
    
}

//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//    return 1;
//}
//
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//    return 10;
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//    return nil;
//}

/*---------------------------------------
 快退
 --------------------------------------- */
- (IBAction)quickBackAction:(id)sender {
//    self.pressSlider.value - (float)15.0;
}
/*---------------------------------------
 快进
 --------------------------------------- */
- (IBAction)quickForwordAction:(id)sender {
//     self.pressSlider.value + (float)15.0;
}
/*---------------------------------------
 上一曲
 --------------------------------------- */
- (IBAction)lastAction:(id)sender {
//    [self changeAudioByIndex:--index];
}
/*---------------------------------------
 下一曲
 --------------------------------------- */
- (IBAction)nextAction:(id)sender {
//    [self changeAudioByIndex:++index];
}
/*---------------------------------------
 播放/暂停
 --------------------------------------- */
- (IBAction)playOrPauseAction:(id)sender {
    [self.player playAudioWithUrl:@"http://ips.ifeng.com/video19.ifeng.com/ugc/video/20151215/audio/20/0a3HuFB000E_64_mp3.mp3"];
    [self.player palyOrPause];
}
/*---------------------------------------
 分享
 --------------------------------------- */
- (IBAction)shareAction:(id)sender {
}
/*---------------------------------------
 下载
 --------------------------------------- */
- (IBAction)downLoadAction:(id)sender {
}
/*---------------------------------------
 评论
 --------------------------------------- */
- (IBAction)commentAction:(id)sender {
}
/*---------------------------------------
 收藏
 --------------------------------------- */
- (IBAction)collectAction:(id)sender {
}
/*---------------------------------------
 更多
 --------------------------------------- */
- (IBAction)moreAction:(id)sender {
}
/*---------------------------------------
 进度条
 --------------------------------------- */
- (IBAction)pressSliderAction:(id)sender {
    [self.player seekTimeToPlay:self.pressSlider.value];
}
/*---------------------------------------
 改变广播的方法
 --------------------------------------- */
- (void)changeAudioByIndex:(NSInteger)index{
    
//    /** 播放音乐 */
//    [self.player playAudioWithUrl:url];
    /** 时间滑条最值 */
//    self.timeSlider.maximumValue = [总时间 floatValue]/ 1000;
    /** 歌手图片 */
//    [self.singerImageView sd_setImageWithURL:[NSURL URLWithString:model.picUrl]];
//    /** 总时间 */
//    [self setupTotalTime:index];
//    /** 歌名 */
//    [self.navigationItem setTitle:model.name];
//    /** 歌词 */
//    self.lyric = [XWLyric shareLyric];
//    [self.lyric creatAllDataArrayWithStr:model.lyric];
//    [self.lyricTableView reloadData];
}

@end
